﻿using Devonline.AspNetCore;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;

namespace Devonline.Identity;

/// <summary>
/// 业务数据带带附件及附加信息的基础数据服务
/// 字符串作为主键的默认实现
/// 一个业务数据中仅有一个类型为: Attachment 的业务数据的附件集合, 根据 BusinessType 字段区分用途
/// 一个业务数据中仅有一个类型为: TAdditional 的附加信息集合
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TAdditional">附加信息数据类型</typeparam>
public interface IDataWithAttachmentAndAdditionalService<TEntitySet, TAdditional> :
    IDataWithAttachmentAndAdditionalService<IdentityDbContext, TEntitySet, TAdditional>,
    IDataWithAttachmentService<TEntitySet>,
    IDataWithAdditionalService<TEntitySet, TAdditional>,
    IDataService<TEntitySet>,
    IDataAttachmentService<TEntitySet>,
    IDataAdditionalService<TEntitySet, TAdditional>,
    IAttachmentService
    where TEntitySet : class, IEntitySet
    where TAdditional : class, IAdditional
{ }

/// <summary>
/// 数据带附件及附加信息的基础数据服务
/// 字符串作为主键的默认实现
/// 业务数据的附件全都在名为 Attachments 的集合中, 根据 BusinessType 字段区分用途
/// </summary>
/// <typeparam name="TEntitySet">业务数据类型</typeparam>
/// <typeparam name="TAdditional">附加信息数据类型</typeparam>
public class DataWithAttachmentAndAdditionalService<TEntitySet, TAdditional> :
    DataWithAttachmentAndAdditionalService<IdentityDbContext, TEntitySet, TAdditional>,
    IDataWithAttachmentAndAdditionalService<TEntitySet, TAdditional>,
    IDataWithAttachmentService<TEntitySet>,
    IDataWithAdditionalService<TEntitySet, TAdditional>,
    IDataService<TEntitySet>,
    IDataAttachmentService<TEntitySet>,
    IDataAdditionalService<TEntitySet, TAdditional>,
    IAttachmentService
    where TEntitySet : class, IEntitySet
    where TAdditional : class, IAdditional
{
    public DataWithAttachmentAndAdditionalService(
        IdentityDbContext context,
        ILogger<DataWithAttachmentAndAdditionalService<TEntitySet, TAdditional>> logger,
        IDistributedCache cache,
        IHttpContextAccessor httpContextAccessor,
        AppSetting appSetting,
        IAttachmentService<IdentityDbContext> attachmentService,
        IDataWithAdditionalService<IdentityDbContext, TEntitySet, TAdditional> dataWithAdditionalService
        ) : base(context, logger, cache, httpContextAccessor, appSetting, attachmentService, dataWithAdditionalService) { }
}